<!-- Page1.vue, Page2.vue, ... -->
<template>
  <div>
    <!-- 页面内容 -->
    <div class="post-list archives" v-for="item in list" :key="item.id">
      <article id="archive">
        <div class="archive-header h2">{{ item.time }}</div>
        <div class="archive-list" v-for="article in item.articles" :key="article.id">
          <router-link class="post fs14" :to="`/blog/article/` + article.id" style="font-weight: bold; font-size: large;">
            <time >{{ formatDate(article.createTime) }}</time>
            <span>{{ article.articleTitle }}</span>
          </router-link>
        </div>
      </article>
    </div>
  </div>
</template>

<script>
import { getArchives } from "@/api/article";

export default {
  mounted() {
    this.getList();
  },
  data() {
    return {
      list: [],
    };
  },
  methods: {
    formatDate(value) {
      if (!value) return '';
      const date = new Date(value);
      return date.toLocaleString('zh-CN', { hour12: false }); // 你可以根据需要调整日期时间格式  
    },
    getList() {
      getArchives().then((res) => {
        this.list = res.data.records;
      });
    },
  },
};
</script>
<style>
</style>
